<?php


	class Player {

		private $id;
		private $name;

		public function __get($attr) {
			return $this->$attr;
		}

		public function setId($id) {
			$this->id = $id;
		}
		
		public function setName($name) {
			$this->name = $name;
		}
                
                public function createPlayer($login, $email, $pw){
                        $sql = "INSERT INTO player
                                (player_login, player_password, player_mail)
                                VALUES (:login, :email, :pw)";
                        $stmt = $this->dbh->prepare($sql);
                        $stmt->bindValue(":login", $login);
                        $stmt->bindValue(":password", $pw);
                        $stmt->bindValue(":email", $email);
                        $stmt->execute();
                }
                
                public function selectPlayer($login){
                        $sql = "SELECT player_id
                                FROM player
                                WHERE player_login = :login
                                OR player_mail = :email";
                        $stmt = $this->dbh->prepare($sql);
                        $stmt->bindValue(":login", $login);
                        $stmt->bindValue(":email", $login);
                        $stmt->execute();
                        $idPlayer = $stmt->fetch();
                        return $idPlayer["player_id"];
                }
	}
	